<?php
/**
 * Created by PhpStorm
 * User: Jhinwy
 * Date: 6/4/24
 * Time: 10:55 AM
 */

namespace App\Services;

use App\Models\WechatAccount;
use App\Models\WechatUserAdmin;

class UtilityService
{
    public static function isRoot()
    {
        return request()->admin->is_root;
    }


    public static function getPermissionUserIds()
    {
        if (self::isRoot()) {
            $userIds = WechatAccount::query()->pluck('user_id')->toArray();
        } else {
            $userIds = WechatUserAdmin::query()->where('admin_id', request()->admin->id)->pluck('user_id')->toArray();
        }

        return array_unique($userIds);
    }
}
